Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] change gateway vald's mutex lock #765

Merged
merged 5 commits into from
Oct 13, 2020

Conversation

kpango
Copy link
Collaborator

@kpango kpango commented Oct 12, 2020

Signed-off-by: kpango i.can.feel.gravity@gmail.com

Description:

replace sync.Mutex lock map using sync.Map CAS operation

Related Issue:

How Has This Been Tested?:

Environment:

  • Go Version: 1.15.2
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.12.1

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 💌 /changelog - add changelog comment
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • /rebase - rebase master

case pos == len(res.GetResults())-1:
res.Results = append(res.GetResults(), dist)
case pos >= 0:
res.Results = append(res.GetResults()[:pos+1], res.GetResults()[pos:]...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci] reported by reviewdog 🐶
appendAssign: append result not assigned to the same slice (gocritic)

break
}
}
switch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci] reported by reviewdog 🐶
anonymous switch statements should never be cuddled (wsl)

for idx := pos; idx >= 1; idx-- {
if res.GetResults()[idx-1].GetDistance() <= dist.GetDistance() {
pos = idx - 1
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci] reported by reviewdog 🐶
break with no blank line before (nlreturn)

@codecov
Copy link

codecov bot commented Oct 12, 2020

Codecov Report

Merging #765 into master will increase coverage by 0.20%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #765      +/-   ##
==========================================
+ Coverage   16.72%   16.92%   +0.20%     
==========================================
  Files         420      421       +1     
  Lines       19476    19528      +52     
==========================================
+ Hits         3258     3306      +48     
  Misses      15997    15997              
- Partials      221      225       +4     
Impacted Files Coverage Δ
pkg/gateway/vald/handler/grpc/handler.go 0.00% <0.00%> (ø)
internal/net/net.go 85.18% <0.00%> (ø)
internal/worker/worker.go 83.33% <0.00%> (+1.04%) ⬆️
internal/errgroup/group.go 93.93% <0.00%> (+1.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6cd738f...44d4bb3. Read the comment docs.

@kpango kpango force-pushed the bugfix/gateway-vald/change-lock-block-for-duplication branch 2 times, most recently from 0060b50 to 9183b07 Compare October 13, 2020 01:49
fix
Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
@kpango kpango force-pushed the bugfix/gateway-vald/change-lock-block-for-duplication branch from 9183b07 to f9373fb Compare October 13, 2020 01:58
pkg/gateway/vald/handler/grpc/handler.go Outdated Show resolved Hide resolved
pkg/gateway/vald/handler/grpc/handler.go Outdated Show resolved Hide resolved
pkg/gateway/vald/handler/grpc/handler.go Outdated Show resolved Hide resolved
fix
Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
@kpango kpango force-pushed the bugfix/gateway-vald/change-lock-block-for-duplication branch from 90498a9 to 0cc6113 Compare October 13, 2020 02:18
@kpango
Copy link
Collaborator Author

kpango commented Oct 13, 2020

@rinx @kmrmt fixed,

Co-authored-by: Rintaro Okamura <rintaro.okamura@gmail.com>
@kpango
Copy link
Collaborator Author

kpango commented Oct 13, 2020

@rinx commit suggestion

@rinx
Copy link
Contributor

rinx commented Oct 13, 2020

Thanks! it became understandable code. 👍

@kpango
Copy link
Collaborator Author

kpango commented Oct 13, 2020

kmrmt's review we don't need to fix it. I'll merge this PR

@kpango kpango merged commit ac40a15 into master Oct 13, 2020
@kpango kpango deleted the bugfix/gateway-vald/change-lock-block-for-duplication branch October 13, 2020 02:26
@kpango kpango mentioned this pull request Oct 13, 2020
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants